package com.ruiysoft.pub.entity;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

/**
 * Created by 化增光 on 2018/4/9.
 */
@Data
public class PageInfo<T> implements Serializable {

    private long pageIndex;
    private long pageSize;
    private long totalCount;
    private List<T> list;

    public PageInfo(Page<T> page) {
        this.pageSize = page.getSize();
        this.pageIndex = page.getCurrent();
        this.list = page.getRecords();
        this.totalCount = page.getTotal();
    }
    public PageInfo(List<T> list,Page page) {
            this.pageSize = page.getSize();
            this.pageIndex = page.getCurrent();
            this.list = list;
            this.totalCount = page.getTotal();
    }

    public PageInfo(List<T> list, PageInfo page) {
        this.pageSize = page.getPageSize();
        this.pageIndex = page.getPageIndex();
        this.list = list;
        this.totalCount = page.getTotalCount();
    }

	public PageInfo(List<T> list, int pageIndex, int pageSize, long totalCount) {
    	this.pageSize = pageSize;
    	this.pageIndex = pageIndex;
    	this.list = list;
    	this.totalCount = totalCount;
	}

    public PageInfo(){
    	this.list = Collections.emptyList();
    }

}
